package anc.tankshooter.models;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {

	public static final long DAY_IN_SECOND=86400;
	private static SimpleDateFormat mDateTimeFormator = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private static SimpleDateFormat mDateFormator = new SimpleDateFormat("yyyy-MM-dd");
	private static SimpleDateFormat mTimeFormator = new SimpleDateFormat("HH:mm");
	
	public static String formatSecond(int s){
		String format="";
		int hour=s/(60*60); s=s%(60*60);
		int minute=s/60; s=s%60;
		return hour+":"+minute+":"+s;
	}
	
	public static String formatTime(int h,int m){
		String format=(h<10?"0"+h:h)+":"+(m<10?"0"+m:m);
		return format;
	}
	
	public static Date toDate(long timeStamp){
		long time=timeStamp*1000l;
		Date d =new Date(time);
		return d;
	}
	
	public static String formatDate(Date d) {
		return mDateFormator.format(d);
	}
	public static String formatDate(long unixTimeStamp) {
		return mDateFormator.format(toDate(unixTimeStamp));
	}
	public static String formatDateTime(Date d) {
		return mDateTimeFormator.format(d);
	}
	public static String formatTime(Date d) {
		return mTimeFormator.format(d);
	}
	public static String formatTime(long unixTimeStamp) {
		return mTimeFormator.format(toDate(unixTimeStamp));
	}
	public static int toTimeStamp(Date d){
		int time = (int)(d.getTime()/1000);
		return time;
	}
}
